﻿<%@ Page Title="" Language="C#" MasterPageFile="~/NestedMasterPageSimple.master" %>

<%@ PreviousPageType VirtualPath="~/Orders/OrderComplete.aspx" %>

<script runat="server">
  protected void Page_Load(object sender, EventArgs e)
  {
    if (!Page.IsPostBack)
    {
      //WEBATM使用POST傳值
      string strOrderNo = CommonUtil.GetRequestValue("CurrentOrderNo");
      string strBuyerName = CommonUtil.GetRequestValue("CurrentBuyerName");


      //0140101~20140228 顯示 恭喜您！本次消費可獲得「長榮航空行李吊牌乙個」，將另行寄送贈品至您指定地址。
      DateTime dt = DateTime.Now;
      if (dt >= Convert.ToDateTime("2014/01/01") & dt < Convert.ToDateTime("2014/03/1"))
      {
        ltlMsg.Text = "　恭喜您！本次消費可獲得「長榮航空行李吊牌乙個」，將另行寄送贈品至您指定地址。";
      }
      
      if (Page.PreviousPage != null)
      {
        if (string.IsNullOrEmpty(strOrderNo) || string.IsNullOrEmpty(strBuyerName))
        {
          //信用卡或銀行付款使用PreviousPage傳值
          strOrderNo = PreviousPage.CurrentOrderNo;
          strBuyerName = PreviousPage.CurrentBuyerName;
        }
      }

      string sreMemberID = "";
      if (!string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))
      {
        sreMemberID = HttpContext.Current.User.Identity.Name;
      }
      //取得訂單明細時，需要傳入訂單編號+購買人姓名
      B2C_MALL_ACCOUNT ws = new B2C_MALL_ACCOUNT();
      ws.Url = ConfigurationManager.AppSettings["B2C_MALL_ACCOUNT"].ToString();
      string strJson = ws.B2C_MALL_GetOrderDetail(CommonUtil.GetWebDevice()
        , sreMemberID, strOrderNo, strBuyerName);
      JObject jObj = JsonConvert.DeserializeObject<JObject>(strJson);
      if (jObj["Is_Valid"].ToString() == "Y")
      {
        ltlOrderNo.Text = strOrderNo;
        ltlOrderDate.Text = jObj["ORDER_DATE"].ToString();
        ltlPayType.Text = CommonUtil.GetPayType(jObj["PAY_TYPE"].ToString());
        ltlReceiverName.Text = jObj["RCVR_Name"].ToString();
        ltlReceiverPhone.Text = jObj["RCVR_TEL_H"].ToString();
        ltlReceiverAddress.Text = jObj["RCVR_ZIP_CODE_RCVR_ADDRESS"].ToString();
        ltlBuyerName.Text = jObj["CUST_NAME"].ToString();
        ltlBuyerAddress.Text = jObj["CUST_ZIP_CODE_CUST_ADDRESS"].ToString();
        ltlBuyerPhone.Text = jObj["CUST_TEL_H"].ToString();
        ltlBuyerCompanyID.Text = jObj["COMPANY_ID"].ToString();
        ltlBuyerCompanyTitle.Text = jObj["COMPANY_NAME"].ToString();
        ltlCellPhoneCode.Text = jObj["CELL_PHONE_CODE"].ToString();
        ltlCharityCode.Text = jObj["CHARITY_CODE"].ToString();
        ltlInvoicePrint.Text = jObj["INVOICE_PRINT_IND"].ToString().Replace("Y", "是").Replace("N", "否");
        if (jObj["PRINT_DETAIL_IND"] != null)
        {
          ltlInvoicePrintDetail.Text = jObj["PRINT_DETAIL_IND"].ToString().Replace("Y", "是").Replace("N", "否");
        }
        ltlPriceSum.Text = string.Format("{0:$ #,##0元}", Convert.ToInt32(jObj["SUB_TOTAL_SUM"].ToString()));
        ltlDiscountSum.Text = string.Format("{0:$ #,##0元}", Convert.ToInt32(jObj["DISCOUNT_AMT"].ToString()));
        ltlECouponSum.Text = string.Format("{0:$ #,##0元}", Convert.ToInt32(jObj["COUPON_AMT"].ToString()));
        ltlTransFee.Text = string.Format("{0:$ #,##0元}", Convert.ToInt32(jObj["FREIGHT_CHARAGE"].ToString()));
        ltlMileSum.Text = jObj["MILEAGE"].ToString() + "哩";
        ltlnTheMoneyWeGet.Text = string.Format("{0:$ #,##0元}", Convert.ToInt32(jObj["RCV_AMT"].ToString()));
        ltlTotal.Text = string.Format("{0:$ #,##0元}", Convert.ToInt32(jObj["RCV_AMT"].ToString()));
        ltlMileSum2.Text = ltlMileSum.Text;
        //購買商品列表
        gvShoppingList.DataSource = (JArray)jObj["pItemList_Ary_List"];
        gvShoppingList.DataBind();

        //銀行匯款時，要顯示銀行匯款相關資料
        if (jObj["PAY_TYPE"].ToString() == "200")
        {
          divPayType2.Visible = true;
        }
        else if (jObj["PAY_TYPE"].ToString() == "500") //ATM
        {
          divPayType3.Visible = true;
        }
      }
    }
  }

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="NestedContent" runat="Server">

  <div class="steps">
    <ul>
      <li>STEP 1. 填寫資料</li>
      <li>STEP 2. 確認資料</li>
      <li class="active">STEP 3. 完成下單</li>
    </ul>
  </div>
  <div class="t-a-r">
    <a href="javascript:window.print();" class="print">列印訂購清單
    </a>
  </div>
  <div class="warning red-text">
    您已完成訂購!
    <asp:Literal ID="ltlMsg" runat="server"></asp:Literal>
  </div>
  <div class="table-title">
    <table>
      <tr>
        <th class="red-text">訂單編號:<asp:Literal ID="ltlOrderNo" runat="server"></asp:Literal></th>
        <th class="t-a-c">訂購日期:<asp:Literal ID="ltlOrderDate" runat="server"></asp:Literal></th>
        <th class="t-a-r">付款方式:<asp:Literal ID="ltlPayType" runat="server"></asp:Literal></th>
      </tr>
    </table>
  </div>

  <div class="info-table">
    <table>
      <tbody>
        <tr class="title">
          <th colspan="4">收件人資料</th>
        </tr>
        <tr>
          <th>姓名</th>
          <td>
            <asp:Literal ID="ltlReceiverName" runat="server"></asp:Literal></td>
          <th>電話</th>
          <td>
            <asp:Literal ID="ltlReceiverPhone" runat="server"></asp:Literal></td>
        </tr>
        <tr>
          <th>地址</th>
          <td>
            <asp:Literal ID="ltlReceiverAddress" runat="server"></asp:Literal></td>
          <th></th>
          <td></td>
        </tr>
        <tr class="title">
          <th colspan="4">購買者資料</th>
        </tr>
        <tr>
          <th>姓名</th>
          <td>
            <asp:Literal ID="ltlBuyerName" runat="server"></asp:Literal></td>
          <th>電話</th>
          <td>
            <asp:Literal ID="ltlBuyerPhone" runat="server"></asp:Literal></td>
        </tr>
        <tr>
          <th>地址</th>
          <td>
            <asp:Literal ID="ltlBuyerAddress" runat="server"></asp:Literal></td>
          <th>發票公司抬頭</th>
          <td>
            <asp:Literal ID="ltlBuyerCompanyTitle" runat="server"></asp:Literal></td>
        </tr>
        <tr>
          <th>統編</th>
          <td>
            <asp:Literal ID="ltlBuyerCompanyID" runat="server"></asp:Literal></td>
          <th>手機條碼</th>
          <td>
            <asp:Literal ID="ltlCellPhoneCode" runat="server"></asp:Literal></td>
        </tr>
        <tr>
          <th>捐贈愛心碼</th>
          <td>
            <asp:Literal ID="ltlCharityCode" runat="server"></asp:Literal></td>
          <th class="longer">是否列印電子發票證明聯</th>
          <td>
            <asp:Literal ID="ltlInvoicePrint" runat="server"></asp:Literal></td>
        </tr>
        <tr>
          <td></td>
          <td></td>
          <th>是否列印購物明細</th>
          <td>
            <asp:Literal ID="ltlInvoicePrintDetail" runat="server"></asp:Literal></td>
        </tr>
      </tbody>
    </table>
  </div>
  <div class="list-table wish">
    <div class="table-title">
      <span class="fl">購物清單</span> <span class="red-text fr">總價 
        <asp:Literal ID="ltlTotal" runat="server"></asp:Literal>
      </span>
    </div>
    <div class="JS_talbe">
      <asp:GridView ID="gvShoppingList" runat="server" AutoGenerateColumns="False" GridLines="None">
        <Columns>
          <asp:BoundField HeaderStyle-CssClass="spacer">
            <HeaderStyle CssClass="spacer"></HeaderStyle>
          </asp:BoundField>
          <asp:TemplateField HeaderText="NO">
            <ItemTemplate>
              <%# Container.DataItemIndex+1 %>
            </ItemTemplate>
            <ItemStyle Width="50px" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="商品圖">
            <ItemTemplate>
              <img src='<%# Server.HtmlEncode(Eval("B2C_IMAGE_PATH").ToString()) %>' style="width: 50px" />
            </ItemTemplate>
            <ItemStyle Width="50px" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="商品名稱">
            <ItemTemplate>
              <%# Server.HtmlEncode(Eval("SMAS_CODE_NAME").ToString()) %>
            </ItemTemplate>
            <ItemStyle Width="230px" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="單價">
            <ItemTemplate>
              $ <%# Server.HtmlEncode(Eval("UNIT_PRICE", "{0:#,##0}").ToString()) %>
            </ItemTemplate>
          </asp:TemplateField>
          <asp:TemplateField HeaderText="數量">
            <ItemTemplate>
              <%# Server.HtmlEncode(Eval("ORDER_QTY", "{0:#,##0}").ToString()) %>
            </ItemTemplate>
            <ItemStyle Width="150px" />
          </asp:TemplateField>
          <asp:TemplateField HeaderText="抵購哩程">
            <ItemTemplate>
              <%# Server.HtmlEncode(Eval("UNIT_MILEAGE", "{0:#,##0}").ToString()) %>
            </ItemTemplate>
          </asp:TemplateField>
          <asp:TemplateField HeaderText="折扣">
            <ItemTemplate>
              <%-- <%# Eval("", "{0:$ #,##0}") %>--%>
            </ItemTemplate>
          </asp:TemplateField>
          <asp:TemplateField HeaderText="規格">
            <ItemTemplate>
              <%# Server.HtmlEncode(Eval("PRODUCT_SPEC_TXT").ToString()) %>
            </ItemTemplate>
          </asp:TemplateField>
          <asp:TemplateField HeaderText="小計">
            <ItemTemplate>
              <%# Server.HtmlEncode(Eval("SUB_TOTAL", "{0:$ #,##0}").ToString()) %>
            </ItemTemplate>
          </asp:TemplateField>
        </Columns>
      </asp:GridView>

      <div class="pink-result-all">
        <div id="divPayType2" runat="server" visible="false" class="left-result fl">
          <h3>銀行匯款</h3>
          <p>
            請列印訂購單並於七個工作日內連同匯款單傳真至 (03) 3510018，
            以便完成訂購程序! 若未在期限內匯款，將取消該筆訂單。
          </p>
          <p class="red-text">
            長榮樂e購帳戶資料: 國泰世華銀行民權分行（銀行代號013）
            帳戶名稱: 長榮航空股份有限公司
            匯款帳號: 019-03-6039003
          </p>
          <p>確認收到款項後商品將於七個工作天內送達。</p>
        </div>
        <div id="divPayType3" runat="server" visible="false" class="left-result fl">
          <h3>國泰世華銀行WebATM</h3>
          <p>
            本公司已收到您的訂單，感謝您訂購長榮樂e購的優質嚴選商品。            
          </p>
          <p class="red-text">
          </p>
          <p>
            我們將在七個工作日內宅配至指定地址，如果您對我們所提供的商品或是服務有任何疑問
            請利用以下方式與我們聯繫
            服務時間: 週一~週五早上9:00~下午5:00
            客戶服務熱線: 0800-535678,03-3515938
            電子郵件信箱: shopping@evaair.com
            客戶服務傳真: 03-3510017,03-3510018 
          </p>
        </div>
        <div class="mini-result">
          <table>
            <tr>
              <th>訂單小計(含稅)</th>
              <td>
                <asp:Literal ID="ltlPriceSum" runat="server" Text="0"></asp:Literal></td>
            </tr>
            <tr>
              <th>折扣金額(含稅)</th>
              <td>-
                <asp:Literal ID="ltlDiscountSum" runat="server" Text="0"></asp:Literal></td>
            </tr>
            <tr>
              <th>E-coupon金額</th>
              <td>-
                <asp:Literal ID="ltlECouponSum" runat="server" Text="0"></asp:Literal></td>
            </tr>
            <tr>
              <th>運費</th>
              <td>
                <asp:Literal ID="ltlTransFee" runat="server" Text="0"></asp:Literal></td>
            </tr>
            <tr class="spaced">
              <th>扣抵總哩程數</th>
              <td>
                <asp:Literal ID="ltlMileSum" runat="server" Text="0"></asp:Literal></td>
            </tr>
            <tr class="red-text">
              <th>消費總計(含稅)</th>
              <td>
                <asp:Literal ID="ltlnTheMoneyWeGet" runat="server" Text="0"></asp:Literal>
                +
                <asp:Literal ID="ltlMileSum2" runat="server" Text="0"></asp:Literal>
              </td>
            </tr>
          </table>
        </div>
      </div>
    </div>
  </div>
  <div>
    <span class="brown-arrow">訂單查詢，您可至
      <asp:HyperLink ID="hlQuery" runat="server" NavigateUrl="javascript:ShowMemberPopup('1');" CssClass="orange-text"> 我的樂e購帳戶 </asp:HyperLink>查詢</span>
  </div>
  <div class="control-links">
    <a class="btn" href="../Home.aspx">回到我的樂e購首頁</a>
  </div>

</asp:Content>

